home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gui / donev102.lha / done / test2.c < prev   
C/C++ Source or Header  |  1996-05-09  |  2KB  |  106 lines

  1. /*
  2. ** Test2.c By Stuart Kelly
  3. **
  4. ** Version: 1.02 - Example of How to use Done1.02 
  5. ** This example shows how you can detect if the user presses the abort
  6. ** button.
  7. ** You may change this code and alter it for your own programs.
  8. **
  9. ** You MAY NOT change done.h and done.o in any way without
  10. ** written permission from the author.
  11. */
  12. #include <stdio.h>
  13. #include <dos/dostags.h>
  14. #include <clib/dos_protos.h>
  15. #include <clib/gadtools_protos.h>
  16. #include <clib/utility_protos.h>
  17. #include "done.h"
  18.  
  19. /* define some varibles */
  20.  
  21. /* change GD_AbortID to GD_Abort because GD_Abort takes less time to type */
  22. #define GD_Abort GD_AbortID
  23.  
  24. struct Window *TheWnd;
  25.  
  26. int quit_a = 0;
  27.  
  28. #define VERSION_STR "Test2 V 1.02 By Stuart Kelly Uses Done V 1.02"
  29.  
  30. char *version = VERSION_STR;
  31.  
  32. void main(void)
  33. {
  34.  struct IntuiMessage *imsg;
  35.  struct IntuiMessage *imsg_copy;
  36.  struct Gadget *gad;
  37.  BOOL quit_now = FALSE;
  38.  
  39.  int a=0;
  40.  
  41.  printf(" Test2 By Stuart Kelly Copyright 1996 ©\n");
  42.  printf(" Uses %s \n", DONE_VERSION_A);
  43.  printf(" Press Return To Continue -> ");
  44.  getchar(); 
  45.  
  46.  ST_WorkReq(NULL);
  47.  
  48.  TheWnd = ST_GetWindow();
  49.  
  50.  if (TheWnd == NULL) { ST_FreeWorkReq();
  51.                       printf(" Window Fail\n");
  52.                       printf(" ARRRRR\n");
  53.                       return; }
  54.  
  55.   while ( !quit_now )
  56.   {
  57.   Wait(1L << TheWnd->UserPort->mp_SigBit);
  58.  
  59.   while (imsg = GT_GetIMsg(TheWnd->UserPort))
  60.    {
  61.     imsg_copy = imsg;
  62.     GT_ReplyIMsg(imsg); /* reply after we copy imsg */
  63.    
  64.     gad = (struct Gadget *)imsg_copy->IAddress;
  65.     switch(imsg_copy->Class)
  66.      {
  67.      case IDCMP_INACTIVEWINDOW:
  68.  
  69.       /* window not active , intuiticks wont work  so activate window */
  70.       ActivateWindow(TheWnd);
  71.  
  72.      break;
  73.      case IDCMP_INTUITICKS:
  74.  
  75.       ST_SetDone(a);
  76.  
  77.       a=a+1;
  78.  
  79.       if (a == ALL_DONE) {
  80.                           ST_SetDone(ALL_DONE);
  81.                           quit_now = TRUE;
  82.                           printf(" Didn't Abort\n");
  83.                           }
  84.  
  85.      break; /* so that we can check if quit_a < 3*/
  86.      case IDCMP_GADGETUP:
  87.       switch(gad->GadgetID)
  88.        {
  89.        case GD_Abort: quit_now = TRUE;
  90.         printf(" You Aborted\n");
  91.        break;
  92.        default: break;
  93.        }
  94.      break;
  95.      default: break;
  96.      } /* switch imsg */
  97.  
  98.      /* reply here, but don't have to as we use a copy of imsg */
  99.    } /* while imsg = */
  100.  
  101.   } /* while ! quit_now */
  102.  
  103.  ST_FreeWorkReq();
  104.  
  105. }
  106.